﻿using System;
using System.Collections.ObjectModel;
using System.Windows.Forms;

namespace Pasta.Medio.Concrete
{
	public class Results : ObservableCollection<Error>
	{
		public bool Success { get; set; }

		public Results() : base()
		{
			Reset();
		}

		public void Reset()
		{
			Success = false;
			Clear();
		}

		public void AddError( string msg, params object[] args)
		{
			AddError(Severity.Error, msg, args);
		}

		public void AddError( Exception ex )
		{
			AddError(Severity.Critical, ex.Message);
		}

		public void AddError(Severity severity, string msg, params object[] args)
		{
			Add(new Error(severity,msg,args));
		}

		public static void CriticalError(string msg, params object[] args)
		{
			string text = String.Format(msg, args);
			MessageBox.Show(text, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			Environment.Exit(-1);
		}
	}
}
